package com.friendsoft.crm.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;

/**
*
* @author huyduong
*/
@Table(name="crm_contact")
@Entity
@XmlAccessorType(XmlAccessType.FIELD)
public class Contact extends BaseEntity {
	private static final long serialVersionUID = 1L;

	@Column(name="last_name")
	private String lastName ;

	@Column(name="first_name")
	private String firstName ;

	@Column(name="middle_name")
	private String middleName ;

	@Column(name="email")
	private String email ;

	@Temporal(TemporalType.TIME)
	@Column(name="birth_date")
	private Date birthDate ;

	@Column(name="url")
	private String url ;

	@ManyToOne
	@JoinColumn(name="user_id")
	@XmlTransient
	private User user ;

	@Column(name="is_main_contact")
	private Boolean isMainContact = false ;

	@OneToMany(mappedBy="contact" , cascade={CascadeType.REFRESH , CascadeType.REMOVE})
	private List<Address> addresses ;

	/**
	 * constructor with parameters : first name and last name
	 */
	public Contact(String firstName,String lastName) {
		this.firstName = firstName;
		this.lastName = lastName;
	}

	/**
	 * @return the lastName
	 */
	public String getLastName() {
		return lastName;
	}

	/**
	 * @param lastName the lastName to set
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	/**
	 * @return the firstName
	 */
	public String getFirstName() {
		return firstName;
	}

	/**
	 * @param firstName the firstName to set
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	/**
	 * @return the middleName
	 */
	public String getMiddleName() {
		return middleName;
	}

	/**
	 * @param middleName the middleName to set
	 */
	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the birthDate
	 */
	public Date getBirthDate() {
		return birthDate;
	}

	/**
	 * @param birthDate the birthDate to set
	 */
	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	/**
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * @param url the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * @param user the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}


	/**
	 * @return the isMainContact
	 */
	public Boolean isMainContact() {
		return isMainContact;
	}

	/**
	 * @param isMainContact the isMainContact to set
	 */
	public void setIsMainContact(Boolean isMainContact) {
		this.isMainContact = isMainContact;
	}

	/**
	 * @return the addresses
	 */
	public List<Address> getAddresses() {
		return addresses;
	}

	/**
	 * @param addresses the addresses to set
	 */
	public void setAddresses(List<Address> addresses) {
		this.addresses = addresses;
	}

	/**
	 * @return the isMainContact
	 */
	public Boolean getIsMainContact() {
		return isMainContact;
	}

	/**
	 * default constructor for contact entity
	 */
	public Contact() {

	}
}
